home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_09_04 / 9n04091a < prev    next >
Text File  |  1991-02-13  |  461b  |  24 lines

  1. /* from cuj */
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5.  
  6. int comp(const void *, const void *);
  7. unsigned char *list[] = {"cat", "car", "cab", "cap", "can"};
  8.  
  9. main()
  10.  
  11.      {
  12.      int x;
  13.      qsort(list, 5, sizeof(unsigned char *), comp);
  14.      for (x = 0; x < 5; x++)
  15.       printf("%s\n", list[x]);
  16.      return 0;
  17.      }
  18.  
  19. int comp(const void *a, const void *b)
  20.      {
  21.      return strcmp( *(char **)a, *(char **)b);
  22.      }
  23.  
  24.